package schedule

import (
	"gin_cli/pkg/cache"
	"gin_cli/pkg/lgz"
	"gin_cli/service"
	"strings"
)

func LgzDeviceOnlineList() {
	defer cronErr()
	var err error
	token := service.GetLgzAccessToken()
	devices, err := lgz.LgzSDK.GetDeviceOnlineList(token)
	if err != nil {
		panic(err)
	}
	for k, v := range devices {
		devices[k] = `"` + v + `"`
	}

	devicesStr := strings.Join(devices, ",")
	devicesStr = "[" + devicesStr + "]"
	cache.Set("lgz_devices", devicesStr, 60)
}
